package com.example.ssm.dao;

import com.example.ssm.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


import java.util.List;

public interface UserDao {
    //得到要登陆的用户   获取想要注册商家的人
    @Select("select * from  onlinesys.user where uname=#{uname}")
    public User getLoginUserByname(User user);
    //注册用户

@Insert("insert into onlinesys.user(uname, pwd, phonenumber, Permission,account) VALUES (#{uname},#{pwd},#{phonenumber},'用户',0)")
    public boolean insertUser( User user);

@Select("select * from  onlinesys.user")
public List<User> selectAllUser();

//模糊查询

    @Select("select * from onlinesys.user where  Permission=#{Permission}")
    public List<User> selectLikePermission(User user);//Permission

    @Select("select * from onlinesys.user where  phonenumber like concat('%',#{phonenumber},'%') and Permission=#{Permission} ")
    public List<User> selectLikePermissionphonenumber(User user);//phonenumber  Permission

    @Select("select * from onlinesys.user where uname like concat('%',#{uname},'%') and  Permission=#{Permission} ")
    public List<User> selectLikeUnamePermission(User user);//uname  Permission


    @Select("select * from onlinesys.user where phonenumber like concat('%',#{uname},'%') and Permission=#{Permission} and uname like concat('%',#{uname},'%') ")
    public List<User> selectLikeUnamePhonenumberPermission(User user);//uname  phonenumber  Permission


    //addShop
    @Insert("insert into onlinesys.user(uname, pwd, phonenumber, Permission,account) VALUES (#{uname},#{pwd},#{phonenumber},'商家',0)")
    public boolean addShop( User user);


    @Select("select * from onlinesys.user where  uname=#{uname}")
    public User selectByName(User user);

@Update("update onlinesys.user set account=#{account} where uname=#{uname}")
   boolean addMoney(User user);




}
